define (require, exports, module) ->
  # 引入样式
  require 'mods/notice_detail/notice_detail_css.css'
  # 引入API服务
  notice_detail_api = require 'mods/notice_detail/notice_detail_api'

  module.exports = Vue.extend

    # 组件模板
    template: require 'mods/notice_detail/notice_detail_tpl.js'

    # 定义变量
    data: () ->
      # 是否加载完成
      loadedSucc: false
      # 加载失败提示语
      loadedFail: ''
      # 当前公告详情
      notice_xq: []

    # 定义方法
    methods:

      # 插件加载
      pluginLoad: () ->
        self = @

      # 加载成功
      loadedSuccFunc: () ->
        self = @
        self.$nextTick () ->
          # 查询公告
          self.getNoticeDetail()
          # 加载成功标识
          self.loadedSucc = true
          # 插件加载
          self.pluginLoad()

      # 获取公告列表
      getNoticeDetail: () ->
        self = @
        # 获取文件类型
        detail_type = self.$route.params.type
        # 获取路由参数
        id = self.$route.params.detail_id

        if "gg" is detail_type

          # 查询公告列表参数
          params =
            notice_id: id

          return notice_detail_api.getNoticeDetail params
            .then (res) ->
              self.notice_xq = res?.body
              # 截取时间
              for notice in self.notice_xq
                notice.updated_at = notice.updated_at.substring 0, 10
            .catch (err) ->
              console.log err
        else
          # 查询公告列表参数
          params =
            law_id: id

          return notice_detail_api.getLawDetail params
            .then (res) ->
              self.notice_xq = res?.body
              # 截取时间
              for notice in self.notice_xq
                notice.updated_at = notice.updated_at.substring 0, 10
            .catch (err) ->
              console.log err

    # 计算属性
    computed:

      # 加载中的样式
      loaddingClass: () ->
        self = @
        if self.loadedSucc
          return 'c-hidden'
        if self.loadedFail
          return 'c-hidden'
        return ''

      # 加载成功的样式
      loadedSuccClass: () ->
        self = @
        return if self.loadedSucc then '' else 'c-vhidden'

      # 加载失败的样式
      loadedFailClass: () ->
        self = @
        return if self.loadedFail then '' else 'c-hidden'

    # 组件初始化执行
    mounted: () ->
      self = @
      # 加载成功 - 处理函数
      return self.loadedSuccFunc()